package com.example.knowledge.adapter;

import android.view.View;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.knowledge.bean.TestKnowChildBean;
import com.example.news.R;

import java.util.List;

public class KnowCourseChildAdapter extends BaseQuickAdapter<TestKnowChildBean, BaseViewHolder> {
    public KnowCourseChildAdapter(int layoutResId, @Nullable List<TestKnowChildBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, TestKnowChildBean item) {
        helper.setText(R.id.tv_title, item.getTitle());
        helper.setText(R.id.tv_author, item.getAuthor());
        helper.setText(R.id.tv_read, item.getRead() + "次阅读");
        helper.setText(R.id.tv_date, item.getDate());
        RelativeLayout relativeLayout = helper.getView(R.id.rl_duration);
        if (!"".equals(item.getDuration())) {
            relativeLayout.setVisibility(View.VISIBLE);
            helper.setText(R.id.tv_duration, item.getDuration());
        } else {
            relativeLayout.setVisibility(View.GONE);
        }
    }
}
